home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 4 / MacFormat n. 4 (Spain) / MacFormat 4.bin / La ciudad del ShareWare / Desarrollo / Little Smalltalk v3.1.4 / Smalltalk Source / graphicsTest.st < prev    next >
Encoding:
Text File  |  1994-09-26  |  1.2 KB  |  59 lines

  1. * ***
  2. * Graphics functions test
  3. *
  4. * Julian Barkway (c) September 1994 All rights reserved. 
  5. * ***
  6. Class    GraphicsTest GraphicsPane win ls le c
  7.   
  8. Methods GraphicsTest 'all'
  9.     new | maxW maxH | 
  10.         maxW <- (smalltalk getMaxScreenArea) right.
  11.         maxW <- 200 min: (maxW - 50).
  12.         maxH <- (smalltalk getMaxScreenArea) bottom.
  13.         maxH <- 200 min: (maxH - 50).
  14.         win <- Window new; 
  15.             title: 'Graphics Test';
  16.             openAt: (20@60) withSize: (maxW@maxH).
  17.         super new; 
  18.              boundsFrom: (-1 @ -1) to: ((win size) + (1 @ 1)); 
  19.              attachTo: win withSizing: (1 @ 1).
  20. |
  21.     draw
  22.         self startDrawing.
  23.         self drawCircle.
  24.         self drawLine.
  25.         self drawRects.
  26.         self endDrawing
  27. |
  28.     drawCircle
  29.         c <- Circle new;
  30.             center: (100@100);
  31.             radius: 50.
  32.         c frame.
  33.         (c center) drawPixel
  34. |
  35.     drawLine
  36.         ls <- (c center) - (c radius).
  37.         ls moveTo.
  38.         le <- (c center) + (c radius).
  39.         le y: (le y) + 20.
  40.         le lineTo.
  41. |
  42.     drawRects | r r2 |
  43.         r <- Rectangle new; 
  44.             upperLeft:   ((ls x)@((le y) - ((c radius * 2) + 30)));
  45.             bottomRight: ((le x)@((le y) - (c radius * 2)));
  46.             frame.
  47.         r inset: (4@4).
  48.         r invert.
  49.         r2 <- Rectangle new;
  50.             upperLeft:   (r upperLeft) - 40;
  51.             bottomRight: (r upperLeft) - 10;
  52.             frame;
  53.             shade: 30;
  54.             paint;
  55.             shade: 100.
  56.         r2 inset: (6@4).
  57.         r2 erase
  58. ]
  59.